import i18n from '@/plugins/i18n';

export default {
  namespaced: true,
  state: {
    language: window.localStorage.getItem('locale') || 'zh',
  },
  getters: {
    getLanguage(state) {
        return state.language
    }
  },
  mutations: {
    setLanguage(state, language) {
      state.language = language;
      i18n.locale =language;
      window.localStorage.setItem('locale', language);
    },
  },
  actions: {
    setLanguage({ commit }, language) {
        commit('setLanguage', language);
    },
  },
}
